package jpa_objects;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 * @author Alejandro Casas
 * @version 1.0
 * @created 10-Dec-2012 1:01:03 AM
 */
@Entity
@NamedQuery(name="searchEvent", query="Select p from Event p  inner join fetch p.sports as s " +
		" inner join fetch p.city as c where s.name = :sport  and c.name = :city and c.country = :country")
public class Event {

	private String ownersMail;
	private String ownersName;
	private String address;
	private String description;
	private String ending_date;
	private long id;
	private double lat;
	private double lng;
	private String miniPicture;
	private int openings;
	private String picture;
	private boolean privacy;
	private String starting_date;
	private String title;
	private List<Comment> comments;
	private List<Sport> sports;
	private City city;
	private List<Player> registered;
	private List<Player> applicants;
	private List<Event_report> reports;
	
	
	

	/**
	 * @return the ownersName
	 */
	public String getOwnersName() {
		return ownersName;
	}

	/**
	 * @param ownersName the ownersName to set
	 */
	public void setOwnersName(String ownersName) {
		this.ownersName = ownersName;
	}

	/**
	 * @return the ownersMail
	 */
	public String getOwnersMail() {
		return ownersMail;
	}

	/**
	 * @param ownersMail the ownersMail to set
	 */
	public void setOwnersMail(String ownersMail) {
		this.ownersMail = ownersMail;
	}

	/**
	 * @return the reports
	 */
	@OneToMany(targetEntity=Event_report.class,cascade=CascadeType.ALL)
	public List<Event_report> getReports() {
		return reports;
	}

	/**
	 * @param reports the reports to set
	 */
	public void setReports(List<Event_report> reports) {
		this.reports = reports;
	}

	/**
	 * @return the address
	 */
	public String getAddress() {
		return address;
	}

	/**
	 * @param address the address to set
	 */
	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the ending_date
	 */
	public String getEnding_date() {
		return ending_date;
	}

	/**
	 * @param ending_date the ending_date to set
	 */
	public void setEnding_date(String ending_date) {
		this.ending_date = ending_date;
	}

	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue
	public long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * @return the lat
	 */
	public double getLat() {
		return lat;
	}

	/**
	 * @param lat the lat to set
	 */
	public void setLat(double lat) {
		this.lat = lat;
	}

	/**
	 * @return the lng
	 */
	public double getLng() {
		return lng;
	}

	/**
	 * @param lng the lng to set
	 */
	public void setLng(double lng) {
		this.lng = lng;
	}

	/**
	 * @return the miniPicture
	 */
	public String getMiniPicture() {
		return miniPicture;
	}

	/**
	 * @param miniPicture the miniPicture to set
	 */
	public void setMiniPicture(String miniPicture) {
		this.miniPicture = miniPicture;
	}

	/**
	 * @return the openings
	 */
	public int getOpenings() {
		return openings;
	}

	/**
	 * @param openings the openings to set
	 */
	public void setOpenings(int openings) {
		this.openings = openings;
	}

	/**
	 * @return the picture
	 */
	public String getPicture() {
		return picture;
	}

	/**
	 * @param picture the picture to set
	 */
	public void setPicture(String picture) {
		this.picture = picture;
	}

	/**
	 * @return the privacy
	 */
	public boolean isPrivacy() {
		return privacy;
	}

	/**
	 * @param privacy the privacy to set
	 */
	public void setPrivacy(boolean privacy) {
		this.privacy = privacy;
	}

	/**
	 * @return the starting_date
	 */
	public String getStarting_date() {
		return starting_date;
	}

	/**
	 * @param starting_date the starting_date to set
	 */
	public void setStarting_date(String starting_date) {
		this.starting_date = starting_date;
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @return the comments
	 */
	@OneToMany(targetEntity=Comment.class,cascade=CascadeType.ALL)
	public List<Comment> getComments() {
		return comments;
	}

	/**
	 * @param comments the comments to set
	 */
	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

	/**
	 * @return the sports
	 */
	@OneToMany(targetEntity=Sport.class,cascade=CascadeType.ALL)
	public List<Sport> getSports() {
		return sports;
	}

	/**
	 * @param sports the sports to set
	 */
	public void setSports(List<Sport> sports) {
		this.sports = sports;
	}

	/**
	 * @return the city
	 */
	@OneToOne(targetEntity=City.class,cascade=CascadeType.ALL)
	public City getCity() {
		return city;
	}

	/**
	 * @param city the city to set
	 */
	public void setCity(City city) {
		this.city = city;
	}

	/**
	 * @return the registered
	 */
	@OneToMany(targetEntity=Player.class,cascade=CascadeType.ALL)
	public List<Player> getRegistered() {
		return registered;
	}

	/**
	 * @param registered the registered to set
	 */
	public void setRegistered(List<Player> registered) {
		this.registered = registered;
	}

	/**
	 * @return the applicants
	 */
	@OneToMany(targetEntity=Player.class,cascade=CascadeType.ALL)
	public List<Player> getApplicants() {
		return applicants;
	}

	/**
	 * @param applicants the applicants to set
	 */
	public void setApplicants(List<Player> applicants) {
		this.applicants = applicants;
	}

	public Event(){

	}

	/**
	 * @param address
	 * @param description
	 * @param ending_date
	 * @param lat
	 * @param lng
	 * @param miniPicture
	 * @param openings
	 * @param picture
	 * @param privacy
	 * @param starting_date
	 * @param title
	 * @param city
	 */
	public Event(String ownersMail,String ownersName,String address, String description, String ending_date,
			double lat, double lng, String miniPicture, int openings,
			String picture, boolean privacy, String starting_date,
			String title, City city,List<Sport> sports) {
		this.ownersName=ownersName;
		this.ownersMail=ownersMail;
		this.address = address;
		this.description = description;
		this.ending_date = ending_date;
		this.lat = lat;
		this.lng = lng;
		this.miniPicture = miniPicture;
		this.openings = openings;
		this.picture = picture;
		this.privacy = privacy;
		this.starting_date = starting_date;
		this.title = title;
		this.city = city;
		comments=new ArrayList<Comment>();
		this.sports=sports;
		
		registered=new ArrayList<Player>();
		applicants=new ArrayList<Player>();
		reports=new ArrayList<Event_report>();
	}

	public void finalize() throws Throwable {

	}

}